PART A - step 2: Wiring the Connections

Now that we have created our HTML layout, let's wire together the player and the HTML elements. We will make the wiring go both ways so that the player can control the FORM elements and the FORM elements can control the player. Try the sample below. You will see that changing the state of the player by clicking on the transport buttons results in the FORM also changing its state to reflect the current state of the player. Conversely, changing the state of the FORM by clicking on any of the radio buttons causes the player to also change its state accordingly.

STOP
PLAY
PAUSE

Let's look at the source. The text that is now highlighted indicates the code that has been added since the previous step. This is the necessary code to tie the FORM and the Beatnik Player together.

<SCRIPT SRC="music-object.js"></SCRIPT>

<SCRIPT LANGUAGE=JavaScript><!-- //

music = new Music ();

function selectRadio (radioNo) {
   document.callbackForm.playState [radioNo].checked = true;
}

music. onStop ('selectRadio (0)');
music.onPlay ('selectRadio (1)');
music.onPause ('selectRadio (2)');


// --></SCRIPT>

<CENTER>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
   <TR VALIGN=CENTER>
      <TD BGCOLOR=000000 ALIGN=CENTER>
         <SCRIPT LANGUAGE=JavaScript>
            music.magicEmbed (
               'SRC="lounge.rmf" ' +
               'WIDTH=144 ' +
               'HEIGHT=60 ' +
               'DISPLAY=SONG ' +
               'AUTOSTART=FALSE ' +
               'LOOP=FALSE ' +
               'HSPACE=20'
            );
         </SCRIPT>
      </TD>
      <TD VALIGN=CENTER>
         <TABLE HEIGHT=100% BORDER=0 CELLSPACING=0 CELLPADDING=8>
            <FORM NAME="callbackForm">
            <TR>
               <TD BGCOLOR=FF0000>
                  <INPUT
                     TYPE=radio
                     NAME=playState
                     ONCLICK="music.stop ()"
                     CHECKED
                  >
                  <FONT FACE="ARIAL,HELVETICA,VERDANA" COLOR=FFFFFF><B>STOP</B></FONT>
               </TD>
            </TR>
            <TR>
               <TD BGCOLOR=00FF00>
                  <INPUT
                     TYPE=radio
                     NAME=playState
                     ONCLICK="music.play ()"
                  >
                  <FONT FACE="ARIAL,HELVETICA,VERDANA" COLOR=000000><B>PLAY</B></FONT>
               </TD>
            </TR>
            <TR>
               <TD BGCOLOR=FFFF00>
                  <INPUT
                     TYPE=radio
                     NAME=playState
                     ONCLICK="music.pause ()"
                  >
                  <FONT FACE="ARIAL,HELVETICA,VERDANA" COLOR=000000><B>PAUSE</B></FONT>
               </TD>
            </TR>
            </FORM>
         </TABLE>
      </TD>
   </TR>
</TABLE>
</CENTER>
<P>